//
//  LoginViewController.m
//  LoninAndRegist
//
//  Created by dlios on 15-3-7.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "LoginViewController.h"

@interface LoginViewController ()

@end

@implementation LoginViewController
-(void)dealloc
{
    [_nameTextField release];
    [_passwordTextField release];
    [_OtherLoginLabel release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title = @"登  陆";
    
    //创建用户名输入框
    self.view.backgroundColor = [UIColor whiteColor];
    self.nameTextField = [[UITextField alloc] initWithFrame:CGRectMake(87.5, 100, 200, 30)];
    self.nameTextField.backgroundColor = [UIColor whiteColor];
    [self.nameTextField.layer setCornerRadius:5];
    [self.nameTextField.layer setBorderColor:[UIColor grayColor].CGColor];
    [self.nameTextField.layer setBorderWidth:0.4];
    self.nameTextField.placeholder = @"           请输入用户名";
    self.nameTextField.clearButtonMode = UITextFieldViewModeAlways;          //清空输入内容
    [self.view addSubview:self.nameTextField];
    
    //创建密码输入框
    self.passwordTextField = [[UITextField alloc] initWithFrame:CGRectMake(self.nameTextField.frame.origin.x, self.nameTextField.frame.origin.y + self.nameTextField.frame.size.height + 25, self.nameTextField.frame.size.width, self.nameTextField.frame.size.height)];
    self.passwordTextField.backgroundColor = [UIColor whiteColor];
    [self.passwordTextField.layer setCornerRadius:5];
    [self.passwordTextField.layer setBorderWidth:0.4];
    [self.passwordTextField.layer setBorderColor:[UIColor grayColor].CGColor];
    self.passwordTextField.placeholder = @"             请输入密码";
    self.passwordTextField.clearButtonMode = UITextFieldViewModeAlways;     //清空输入内容
    [self.view addSubview:self.passwordTextField];
    
    //创建登陆按钮
    self.loginButton = [UIButton buttonWithType:UIButtonTypeCustom];
    //self.loginButton.backgroundColor = [UIColor redColor];
    self.loginButton.frame = CGRectMake(self.passwordTextField.frame.origin.x, self.passwordTextField.frame.origin.y + self.passwordTextField.frame.size.height + 35, 85, 30);
    [self.loginButton setBackgroundImage:[UIImage imageNamed:@"shake_prize_phone@2x.png"] forState:UIControlStateNormal];
    [self.loginButton setTitle:@"登  陆" forState:UIControlStateNormal];
    [self.loginButton.layer setCornerRadius:5];
    [self.view addSubview:self.loginButton];
    [self.loginButton addTarget:self action:@selector(LoginAction:) forControlEvents:UIControlEventTouchUpInside];
    
    //创建注册按钮
    self.registButton = [UIButton buttonWithType:UIButtonTypeCustom];
    //self.registButton.backgroundColor = [UIColor redColor];
    self.registButton.frame = CGRectMake(self.passwordTextField.frame.origin.x + self.loginButton.frame.size.width + 30, self.passwordTextField.frame.origin.y + self.passwordTextField.frame.size.height + 35, self.loginButton.frame.size.width, self.loginButton.frame.size.height);
    [self.registButton setBackgroundImage:[UIImage imageNamed:@"shake_prize_phone@2x.png"] forState:UIControlStateNormal];
    [self.registButton setTitle:@"注  册" forState:UIControlStateNormal];
    
    [self.registButton.layer setCornerRadius:5];
    [self.view addSubview:self.registButton];
    [self.registButton addTarget:self action:@selector(registAction:) forControlEvents:UIControlEventTouchUpInside];
    
    //创建其他登录方式Label
    self.OtherLoginLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.loginButton.frame.origin.y + self.loginButton.frame.size.height + 100, 375, 35)];
    //添加Label背景图片
    [self.OtherLoginLabel setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"gradualChangeUnderText.png"]]];
    //[self.OtherLoginLabel setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"mine_header_bkg.png"]]];
    self.OtherLoginLabel.text = @"                      使用其他登录方式登陆";
    [self.view addSubview:self.OtherLoginLabel];
    
    //创建第三方登陆按钮
    self.QQLogButton = [UIButton buttonWithType:UIButtonTypeCustom];
    //self.QQLogButton.backgroundColor = [UIColor redColor];
    self.QQLogButton.frame = CGRectMake(self.OtherLoginLabel.frame.origin.x + 60, self.OtherLoginLabel.frame.origin.y + self.OtherLoginLabel.frame.size.height + 70, 50, 50);
    [self.QQLogButton setBackgroundImage:[UIImage imageNamed:@"share_QQ@2x.png"] forState:UIControlStateNormal];
    [self.QQLogButton.layer setCornerRadius:5];
    [self.view addSubview:self.QQLogButton];
    [self.QQLogButton addTarget:self action:@selector(QQAction:) forControlEvents:UIControlEventTouchUpInside];
    
    self.XinLangLoginButton = [UIButton buttonWithType:UIButtonTypeCustom];
    //self.XinLangLoginButton.backgroundColor = [UIColor redColor];
    self.XinLangLoginButton.frame = CGRectMake(self.QQLogButton.frame.origin.x + self.QQLogButton.frame.size.width + 52.5, self.OtherLoginLabel.frame.origin.y + self.OtherLoginLabel.frame.size.height + 70, self.QQLogButton.frame.size.width, self.QQLogButton.frame.size.height);
    [self.XinLangLoginButton setBackgroundImage:[UIImage imageNamed:@"share_sina@2x.png"] forState:UIControlStateNormal];
    [self.XinLangLoginButton.layer setCornerRadius:5];
    [self.view addSubview:self.XinLangLoginButton];
    [self.XinLangLoginButton addTarget:self action:@selector(xinLangAction:) forControlEvents:UIControlEventTouchUpInside];
    
    self.WinxinLogButton = [UIButton buttonWithType:UIButtonTypeCustom];
    //self.WinxinLogButton.backgroundColor = [UIColor redColor];
    self.WinxinLogButton.frame = CGRectMake(self.XinLangLoginButton.frame.origin.x + self.XinLangLoginButton.frame.size.width + 52.5, self.OtherLoginLabel.frame.origin.y + self.OtherLoginLabel.frame.size.height + 70, self.QQLogButton.frame.size.width, self.QQLogButton.frame.size.height);
    [self.WinxinLogButton setBackgroundImage:[UIImage imageNamed:@"share_wexin@3x.png"] forState:UIControlStateNormal];
    [self.WinxinLogButton.layer setCornerRadius:5];
    [self.view addSubview:self.WinxinLogButton];
    [self.WinxinLogButton addTarget:self action:@selector(winXinAction:) forControlEvents:UIControlEventTouchUpInside];
    
    
    //创建收回模态按钮
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:@selector(blockAction:)];
    
}

//登陆按钮事件
-(void)LoginAction:(UIButton *)button
{
    NSLog(@"登陆");
    
}


//注册按钮事件
-(void)registAction:(UIButton *)button
{
    NSLog(@"注册");
    RegistViewController *registVC = [[RegistViewController alloc] init];
    [self.navigationController pushViewController:registVC animated:YES];
}

//QQ登陆按钮事件
-(void)QQAction:(UIButton *)button
{
    NSLog(@"QQ");
}

//新浪登陆事件
-(void)xinLangAction:(UIButton *)button
{
    NSLog(@"新浪");
}

//微信登陆按钮事件
-(void)winXinAction:(UIButton *)button
{
    NSLog(@"微信");
}


//键盘回收
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self.nameTextField resignFirstResponder];
    [self.passwordTextField resignFirstResponder];
}


//收回PUSH事件
-(void)blockAction:(UIBarButtonItem *)barButton
{
    [self.navigationController popViewControllerAnimated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
